<template>
	<mtable :data="data" :type="typeTable" :list="list" :tableheight="'200'"
		:operation="false"  @handleAdds="handleAdds">
		<template #tool="{item}">
			<el-table-column v-if="item.display==1" sortable :label="item.name" :prop="item.value"
				:width="item.width" show-overflow-tooltip>
				<template #default="{ row }">
					<div v-if="item.name=='数量'&&row.category_id==15">
						<span>
							{{row.unit_length}}{{row.unit_name_15}}/{{row.unit_name}}
						</span>
						<span style="margin-left: 10px;">
							{{row.quantity}}{{row.unit_name}}
						</span>
						<span style="margin-left: 10px;color: #409eff;">
							{{row.subtotal}}{{row.unit_name_15}}
						</span>
					</div>
					<div v-if="item.name=='数量'&&row.category_id!==15">
						<span>
							{{row.quantity}}{{row.unit_name}}
						</span>
					</div>
					
					<div v-if="item.name=='单据类型'">
						<el-button v-if="row.type_name=='报废单'" size="small" color="#ECB361"
							plain>{{row.type_name}}
						</el-button>
						<el-button v-if="row.type_name=='调拨单'" size="small" color="#38ddcd"
							plain>{{row.type_name}}
						</el-button>
						<el-button v-if="row.type_name=='入库单'" size="small" color="#ae75ef"
							plain>{{row.type_name}}
						</el-button>
						
					</div>

                    <div v-if="item.name=='业务类型'">
						<el-button v-if="row.business_type=='入库'" size="small" color="#67C23A"
							plain>{{row.business_type}}
						</el-button>
						<el-button v-if="row.business_type=='出库'" size="small" color="#F56C6C"
							plain>{{row.business_type}}
						</el-button>
						<el-button v-if="row.business_type=='报废'" size="small" color="#E82DA3"
							plain>{{row.business_type}}
						</el-button>
						
					</div>
					<div v-if="item.name=='状态'">
						<el-button v-if="row.status_name=='待入库'" size="small" color="#E6A23C" plain>
							{{row.status_name}}
						</el-button>
						<el-button v-if="row.status_name=='已作废'" size="small" color="#c8cacc" plain>
							{{row.status_name}}
						</el-button>
						<el-button v-if="row.status_name=='已入库'" size="small" color="#67C23A" plain>
							{{row.status_name}}
						</el-button>
						<el-button v-if="row.status_name=='待出库'" size="small" color="#58c1ee" plain>
							{{row.status_name}}
						</el-button>
						<el-button v-if="row.status_name=='已驳回'" size="small" color="#F56C6C" plain>
							{{row.status_name}}
						</el-button>
						<el-button v-if="row.status_name=='待报废'" size="small" color="#9C565D" plain>
							{{row.status_name}}
						</el-button>
						<el-button v-if="row.status_name=='已报废'" size="small" color="#E82DA3" plain>
							{{row.status_name}}
						</el-button>
					</div>
				</template>
			</el-table-column>
		</template>
	</mtable>
	<edit-popup v-if="showEdits" ref="editRefing" :className="'aac'" :type="typeTable" @success="onsuccess" @close="showEdits = false" />
</template>

<script lang="ts" setup>
	import mtable from '@/components/table/index.vue'
	import EditPopup from '@/components/settable/index.vue'
	const props = defineProps([
		'data',
		'typeTable',
		'list'
	])
	const emit = defineEmits(['onsuccess'])
	const editRefing = shallowRef < InstanceType < typeof EditPopup >> ()
	const showEdits = ref(false)
	const typeTable = ref('history_detail')
	const handleAdds = async () => {
		showEdits.value = true
		await nextTick()
		editRefing.value?.open('add')
	}
	const onsuccess =()=>{
		emit('onsuccess')
	}
</script>

<style>
</style>